<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSmsRecordsTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sms_records', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('template_id')->comment('模板ID');
            $table->unsignedInteger('user_id')->comment('用户ID');
            $table->unsignedInteger('task_id')->nullable()->comment('任务ID');
            $table->string('phone', 20)->comment('电话号码');
            $table->text('content')->comment('发送内容');
            $table->string('request_id')->comment('请求ID');
            $table->string('biz_id')->comment('发送回执ID，可查询发送状态');
            $table->unsignedInteger('status')->default(0)->comment('状态：0:请求成功,1:发送成功,2:发送失败');
            $table->unsignedTinyInteger('is_readed')->default(0)->comment('是否已读，0:未读,1:已读');
            $table->unsignedTinyInteger('type')->default(0)->comment('类型，0:任务通知,1:新咨询通知,2:咨询更新通知');
            $table->string('data_scope')->nullable()->comment('数据域');
            $table->timestamps();

            $table->comment = '短信通知记录表';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sms_records');
    }

}
